/**
 * 漆水河 脚手架基础公开课
 * 2022/8/13 --- 2022/12/13
 * 有疑问可加QQ群: 809126489，后续会持续输出与大家一起成长
 */
package com.qishuihe.common.domain.role.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qishuihe.baseinterface.constant.CommonConstant;
import com.qishuihe.common.domain.role.service.RoleUserRelationService;
import com.qishuihe.common.domain.role.mapper.RoleUserRelationMapper;
import com.qishuihe.common.domain.role.entity.RoleUserRelationEntity;
import com.qishuihe.baseinterface.basevo.vo.ResultVO;
import com.qishuihe.outbound.user.RoleUserDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

@Service
public class RoleUserRelationServiceImpl extends ServiceImpl<RoleUserRelationMapper, RoleUserRelationEntity> implements RoleUserRelationService {

    @Override
    public ResultVO<RoleUserDTO> modifyRoleUser(RoleUserDTO roleUserDTO) {
        ResultVO<RoleUserDTO> resultDto =  new ResultVO<RoleUserDTO>();
        RoleUserRelationEntity roleUserRelationEntity = new RoleUserRelationEntity();
        BeanUtils.copyProperties(roleUserDTO,roleUserRelationEntity);
        if(!super.saveOrUpdate(roleUserRelationEntity)){
            resultDto.setCode(CommonConstant.STATUS_ERROR);
            resultDto.setMessage("修改用户失败");
            resultDto.setObj(roleUserDTO);
        }else {
            BeanUtils.copyProperties(roleUserRelationEntity, roleUserDTO);
            resultDto.setObj(roleUserDTO);
        }
        return resultDto;
    }

}
